/**
 * Created by liuyanjun on 2017/6/8.
 */
import Vue from 'Vue'
import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios,axios);

var instance = axios.create({
  baseURL : 'http://localhost:8081/api/',
  timeout:1000,
  headers:{'X-Custom-Header':'foobar'}
});
if(localStorage.getItem('user')){
    instance.default.headers.common['Authorization']='Bearer ' + localStorage.getItem('user').replace(/(^\")|(\"$)/g, '');
}

export default {
    localLogin: function(data){
        return Vue.axios.post('/api/login',data);
    },
    localLogout: function (data) {
        return instance.post('/api/logout',data);
    },
    localReg:function (data) {
        return Vue.axios.post('/api/reg',data);
    }
}
